import QtQuick 2.15
import QtQuick.Controls 2.15
import QtGraphicalEffects 1.15
import './../controls'
//输入手环窗口
Popup {
    id:pop
    width: 460
    height: 200
    //    modal: true
    anchors.centerIn: parent
    property var pWin: null
    property var goodData: null
    property var orderInfo: null
    property url qmlPath: ''
    property var properties:null
    property bool isAddPage: true
    //    closePolicy:Popup.NoAutoClose
    background:BorderImage {
        anchors.fill: parent
        anchors.leftMargin: -16
        anchors.rightMargin: -16
        anchors.topMargin: -12
        anchors.bottomMargin: -20
        border.left: 16
        border.right: 16
        border.top: 12
        border.bottom: 20
        source: "qrc:/images/DialogFrame3.png"
    }
    onClosed:{
        pop.destroy()
    }

    onOpened: {
        forceActiveFocus()
    }
    contentItem: Item {
        anchors.fill: parent
        anchors.margins: 20
        Row{
            anchors.centerIn: parent
            spacing: 10
            Rectangle{
                width: 320
                height: 43
                color: '#4cC2C2C2'
                radius:5
                TextField{
                    id:textNum
                    x:10
                    height: parent.height-2
                    width: parent.width - x - 4
                    font.pixelSize: 14
                    maximumLength:30
                    color: '#333333'
                    focus: true
                    placeholderText: qsTr('请输入手环号')
                    anchors.verticalCenter: parent.verticalCenter
                    selectByMouse: true
                    background: Item{}
                    Component.onCompleted: {
                        forceActiveFocus();
                    }

                    Keys.onPressed: {
                        if (event.key === Qt.Key_Return || event.key === Qt.Key_Enter) {
                           btn.clicked()
                        }
                    }
                }
            }
            Button{
                id:btn
                width: 80
                height: 40
                anchors.verticalCenter: parent.verticalCenter
                focusPolicy:Qt.NoFocus
                background: Rectangle{
                    radius: 10
                    color: '#EA9508'
                    Text {
                        anchors.centerIn: parent
                        color: '#ffffff'
                        text: qsTr("确定")
                    }
                }
                onClicked: {
                    if(textNum.text.length > 0)
                    {
                        properties['bno']=textNum.text
                        if(isAddPage)
                        {
                           window.addPage(qmlPath,properties)
                        }
                        else
                        {
                            CGlobal.createObjectAndOpen(window,qmlPath,properties)
                        }
                    }
                    pop.close()
                }
            }
        }
    }
}
